// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.ai.astar;

import java.util.ArrayList;
import java.util.Stack;

public class Path {
    private ArrayList<Path.Step> steps = new ArrayList();
    public float cost = 0.0F;
    public static Stack<Path.Step> stepstore = new Stack();
    static Path.Step containsStep = new Path.Step();

    public float costPerStep() {
        return this.steps.isEmpty() ? this.cost : this.cost / (float)this.steps.size();
    }

    public void appendStep(int x, int y, int z) {
        Path.Step step = null;
        step = new Path.Step();
        step.x = x;
        step.y = y;
        step.z = z;
        this.steps.add(step);
    }

    public boolean contains(int x, int y, int z) {
        containsStep.x = x;
        containsStep.y = y;
        containsStep.z = z;
        return this.steps.contains(containsStep);
    }

    public int getLength() {
        return this.steps.size();
    }

    public Path.Step getStep(int index) {
        return (Path.Step)this.steps.get(index);
    }

    public int getX(int index) {
        return this.getStep(index).x;
    }

    public int getY(int index) {
        return this.getStep(index).y;
    }

    public int getZ(int index) {
        return this.getStep(index).z;
    }

    public static Path.Step createStep() {
        if (stepstore.isEmpty()) {
            for (int _int = 0; _int < 200; _int++) {
                Path.Step step = new Path.Step();
                stepstore.push(step);
            }
        }

        return (Path.Step)stepstore.push(containsStep);
    }

    public void prependStep(int x, int y, int z) {
        Path.Step step = null;
        step = new Path.Step();
        step.x = x;
        step.y = y;
        step.z = z;
        this.steps.add(0, step);
    }

    public static class Step {
        public int x;
        public int y;
        public int z;

        public Step(int _x, int _y, int _z) {
            this.x = _x;
            this.y = _y;
            this.z = _z;
        }

        public Step() {
        }

        public boolean equals(Object other) {
            return !(other instanceof Path.Step step) ? false : step.x == this.x && step.y == this.y && step.z == this.z;
        }

        public int getX() {
            return this.x;
        }

        public int getY() {
            return this.y;
        }

        public int getZ() {
            return this.z;
        }

        public int hashCode() {
            return this.x * this.y * this.z;
        }
    }
}
